package com.game.business.controller;


import java.util.Arrays;
import java.util.List;
import java.io.IOException;

import com.game.common.annotation.Log;
import com.game.common.core.controller.BaseController;
import com.game.common.core.domain.AjaxResult;
import com.game.common.enums.BusinessType;
import com.game.common.utils.poi.ExcelUtil;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.game.business.domain.TOrderDbrRecord;
import com.game.business.service.ITOrderDbrRecordService;
import com.game.common.core.page.TableDataInfo;

/**
 * 订单担保人Controller
 *
 * @author ruoyi
 * @date 2025-10-15
 */
@RestController
@RequestMapping("/business/orderDbrRecord")
public class TOrderDbrRecordController extends BaseController {
    @Autowired
    private ITOrderDbrRecordService tOrderDbrRecordService;

/**
 * 查询订单担保人列表
 */
//@RequiresPermissions("business:orderDbrRecord:list")
@GetMapping("/list")
    public TableDataInfo list(TOrderDbrRecord tOrderDbrRecord) {
        startPage();
        List<TOrderDbrRecord> list = tOrderDbrRecordService.selectTOrderDbrRecordList(tOrderDbrRecord);
        return getDataTable(list);
    }

    /**
     * 导出订单担保人列表
     */
    //@RequiresPermissions("business:orderDbrRecord:export")
    @Log(title = "订单担保人", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TOrderDbrRecord tOrderDbrRecord) {
        List<TOrderDbrRecord> list = tOrderDbrRecordService.selectTOrderDbrRecordList(tOrderDbrRecord);
        ExcelUtil<TOrderDbrRecord> util = new ExcelUtil<TOrderDbrRecord>(TOrderDbrRecord. class);
        util.exportExcel(response, list, "订单担保人数据");
    }

    /**
     * 获取订单担保人详细信息
     */
    //@RequiresPermissions("business:orderDbrRecord:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(tOrderDbrRecordService.getById(id));
    }

    /**
     * 新增订单担保人
     */
    //@RequiresPermissions("business:orderDbrRecord:add")
    @Log(title = "订单担保人", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TOrderDbrRecord tOrderDbrRecord) {
        return toAjax(tOrderDbrRecordService.save(tOrderDbrRecord));
    }

    /**
     * 修改订单担保人
     */
    //@RequiresPermissions("business:orderDbrRecord:edit")
    @Log(title = "订单担保人", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TOrderDbrRecord tOrderDbrRecord) {
        return toAjax(tOrderDbrRecordService.updateById(tOrderDbrRecord));
    }

    /**
     * 删除订单担保人
     */
    //@RequiresPermissions("business:orderDbrRecord:remove")
    @Log(title = "订单担保人", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(tOrderDbrRecordService.removeByIds(Arrays.asList(ids)));
    }
}
